package data;

import org.apache.commons.lang3.ArrayUtils;

public class Message extends Data {

	public Message(String message) {
		this.data=message.getBytes();
	}

	public Message(byte[] data) {
		super(data);
	}

	@Override
	public byte[] getDataWithHeader() {
		short len = (short)(data.length+3);
		byte[] header = new byte[3];
		
		header[0] = (byte)len;
		header[1] = (byte)(len >> 8);
		header[2] = Data.MESSAGE;
		byte[] bytes = ArrayUtils.addAll(header, data);
		return bytes;
	}

	
	@Override
	protected void process(short len) {
		//Output as String
        String foo = new String(data);
        System.out.println(foo);
        //Output as Bytes
		//for(byte bite:bytesReceived) {
		//	System.out.print(bite+" ");
		//}
        //System.out.println();
	}


}
